﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Drawing;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Windows.Forms;
using Autodesk.Revit.UI;
using HYElectricCalculation;
using HYElectricCommon;
using HYFamilyLibDataManager;
using Microsoft.CSharp.RuntimeBinder;
using Microsoft.Office.Interop.Excel;
using Microsoft.Office.Interop.Word;

namespace YArchitech.Revit.MEP.Calculator
{
	public class DataCalculationAndHelper
	{
		private void DatagridViewExportXml(DataGridView dgv)
		{
		}

		public static void ExportDataGridView(List<DataGridView> dgvList, LoadCalculationForms form)
		{
			object value = Missing.Value;
			Microsoft.Office.Interop.Word.Application application = (Microsoft.Office.Interop.Word.Application)Activator.CreateInstance(Marshal.GetTypeFromCLSID(new Guid("000209FF-0000-0000-C000-000000000046")));
			Document document = application.Documents.Add(ref value, ref value, ref value, ref value);
			application.Visible = true;
			Paragraph paragraph = document.Paragraphs.Add(ref value);
			Microsoft.Office.Interop.Word.Range range = paragraph.Range;
			range.Text = "负荷计算书";
			range.Font.Size = 30f;
			range.Font.Bold = 1;
			paragraph.Alignment = WdParagraphAlignment.wdAlignParagraphCenter;
			paragraph.Format.SpaceAfter = 24f;
			range.InsertParagraphAfter();
			Paragraph paragraph2 = document.Paragraphs.Add(ref value);
			Microsoft.Office.Interop.Word.Range range2 = paragraph2.Range;
			range2.Text = "计算依据";
			range2.Font.Size = 20f;
			range2.Font.Bold = 1;
			paragraph2.Alignment = WdParagraphAlignment.wdAlignParagraphLeft;
			paragraph2.Format.SpaceAfter = 10f;
			range2.InsertParagraphAfter();
			Microsoft.Office.Interop.Word.Range range3 = paragraph2.Range;
			range3.Text = "《工业与民用配电设计手册》第三版";
			paragraph2.Alignment = WdParagraphAlignment.wdAlignParagraphLeft;
			paragraph2.Format.SpaceAfter = 2f;
			range3.InsertParagraphAfter();
			Microsoft.Office.Interop.Word.Range range4 = paragraph2.Range;
			range4.Text = "《现代建筑电气设计实用指南》";
			paragraph2.Alignment = WdParagraphAlignment.wdAlignParagraphLeft;
			paragraph2.Format.SpaceAfter = 10f;
			range4.InsertParagraphAfter();
			Microsoft.Office.Interop.Word.Range range5 = paragraph2.Range;
			range5.Text = "计算结果";
			range5.Font.Size = 20f;
			range5.Font.Bold = 1;
			paragraph2.Alignment = WdParagraphAlignment.wdAlignParagraphLeft;
			paragraph2.Format.SpaceAfter = 24f;
			range5.InsertParagraphAfter();
			DataGridView dataGridView = dgvList[0];
			Microsoft.Office.Interop.Word.Range range6 = document.Paragraphs.Add(ref value).Range;
			Table table = document.Tables.Add(range6, dataGridView.Rows.Count - 1, dataGridView.Columns.Count, ref value, ref value);
			table.Borders.OutsideLineStyle = WdLineStyle.wdLineStyleSingle;
			table.Borders.InsideLineStyle = WdLineStyle.wdLineStyleSingle;
			DataCalculationAndHelper.SetTable(table, dataGridView);
			object obj = WdUnits.wdLine;
			int num = 20;
			Selection selection = application.Selection;
			object obj2 = num;
			object obj3 = Missing.Value;
			selection.MoveDown(ref obj, ref obj2, ref obj3);
			obj = WdUnits.wdLine;
			application.Selection.TypeParagraph();
			Microsoft.Office.Interop.Word.Range range7 = paragraph2.Range;
			range7.Text = "计算结果(不计入补偿容量)：";
			range7.Font.Size = 10f;
			paragraph2.Alignment = WdParagraphAlignment.wdAlignParagraphLeft;
			paragraph2.Format.SpaceAfter = 10f;
			range7.InsertParagraphAfter();
			DataGridView dataGridView2 = dgvList[1];
			Microsoft.Office.Interop.Word.Range range8 = document.Paragraphs.Add(ref value).Range;
			Table table2 = document.Tables.Add(range8, dataGridView2.Rows.Count + 1, dataGridView2.ColumnCount, ref value, ref value);
			table2.Borders.OutsideLineStyle = WdLineStyle.wdLineStyleSingle;
			table2.Borders.InsideLineStyle = WdLineStyle.wdLineStyleSingle;
			DataCalculationAndHelper.SetTable(table2, dataGridView2);
			object obj4 = WdUnits.wdLine;
			Selection selection2 = application.Selection;
			obj3 = num;
			obj2 = Missing.Value;
			selection2.MoveDown(ref obj4, ref obj3, ref obj2);
			obj4 = WdUnits.wdLine;
			application.Selection.TypeParagraph();
			Microsoft.Office.Interop.Word.Range range9 = paragraph2.Range;
			range9.Text = "计算结果(计入补偿容量)：";
			range9.Font.Size = 10f;
			paragraph2.Alignment = WdParagraphAlignment.wdAlignParagraphLeft;
			paragraph2.Format.SpaceAfter = 10f;
			range9.InsertParagraphAfter();
			DataGridView dataGridView3 = dgvList[2];
			Microsoft.Office.Interop.Word.Range range10 = document.Paragraphs.Add(ref value).Range;
			Table table3 = document.Tables.Add(range10, dataGridView3.Rows.Count + 1, dataGridView3.ColumnCount, ref value, ref value);
			table3.Borders.OutsideLineStyle = WdLineStyle.wdLineStyleSingle;
			table3.Borders.InsideLineStyle = WdLineStyle.wdLineStyleSingle;
			DataCalculationAndHelper.SetTable(table3, dataGridView3);
			Microsoft.Office.Interop.Word.Range range11 = paragraph2.Range;
			range11.Text = "变压器选型：";
			range11.Font.Size = 10f;
			paragraph2.Alignment = WdParagraphAlignment.wdAlignParagraphLeft;
			paragraph2.Format.SpaceAfter = 10f;
			range11.InsertParagraphAfter();
			object obj5 = WdUnits.wdLine;
			Selection selection3 = application.Selection;
			obj2 = num;
			obj3 = Missing.Value;
			selection3.MoveDown(ref obj5, ref obj2, ref obj3);
			application.Selection.TypeParagraph();
			Microsoft.Office.Interop.Word.Range range12 = document.Paragraphs.Add(ref value).Range;
			Table table4 = document.Tables.Add(range12, 1, 8, ref value, ref value);
			table4.Borders.OutsideLineStyle = WdLineStyle.wdLineStyleSingle;
			table4.Borders.InsideLineStyle = WdLineStyle.wdLineStyleSingle;
			table4.Cell(1, 1).Range.Text = "负荷率：";
			table4.Cell(1, 2).Range.Text = form.tbLoadFactor.Text;
			table4.Cell(1, 3).Range.Text = "变压器名称：";
			TransformPowerData transformPowerData = (TransformPowerData)form.cmbTransformType.SelectedItem;
			table4.Cell(1, 4).Range.Text = transformPowerData.TransformName;
			table4.Cell(1, 5).Range.Text = "台数：";
			table4.Cell(1, 6).Range.Text = form.numCount.Value.ToString();
			table4.Cell(1, 7).Range.Text = "变压器规格：";
			table4.Cell(1, 8).Range.Text = form.cmbTranPower.SelectedItem.ToString();
		}

		public static void SetTable(Table table, DataGridView srcDgv)
		{
			int count = srcDgv.Rows.Count;
			int count2 = srcDgv.Columns.Count;
			table.Range.Font.Size = 10f;
			table.Range.Font.Bold = 0;
			for (int i = 0; i < count2; i++)
			{
				table.Cell(1, i + 1).Range.Text = srcDgv.Columns[i].HeaderText;
			}
			for (int j = 0; j < count; j++)
			{
				for (int k = 0; k < count2; k++)
				{
					object value = srcDgv.Rows[j].Cells[k].Value;
					if (count >= 3 && count - 3 == j)
					{
						break;
					}
					int row;
					if (count >= 3 && count - 1 == j)
					{
						row = j + 1;
					}
					else
					{
						row = j + 2;
					}
					if (value == null)
					{
						table.Cell(row, k + 1).Range.Text = "";
					}
					else
					{
						table.Cell(row, k + 1).Range.Text = value.ToString();
					}
				}
			}
		}

		public static void ExportDataGridViewToWord(DataGridView srcDgv)
		{
			if (srcDgv.Rows.Count == 0)
			{
				MessageBox.Show("没有数据可供导出！", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
				return;
			}
			SaveFileDialog saveFileDialog = new SaveFileDialog();
			saveFileDialog.AddExtension = true;
			saveFileDialog.DefaultExt = ".doc";
			saveFileDialog.Filter = "(*.doc)|*.doc";
			if (saveFileDialog.ShowDialog() == DialogResult.OK)
			{
				object fileName = saveFileDialog.FileName;
				object value = Missing.Value;
				Microsoft.Office.Interop.Word.Application application = (Microsoft.Office.Interop.Word.Application)Activator.CreateInstance(Marshal.GetTypeFromCLSID(new Guid("000209FF-0000-0000-C000-000000000046")));
				Document document = application.Documents.Add(ref value, ref value, ref value, ref value);
				Table table = document.Tables.Add(document.Paragraphs.Last.Range, srcDgv.Rows.Count, srcDgv.Columns.Count, ref value, ref value);
				try
				{
					for (int i = 0; i < srcDgv.Columns.Count; i++)
					{
						table.Cell(0, i + 1).Range.Text = srcDgv.Columns[i].HeaderText;
					}
					for (int j = 1; j < srcDgv.Rows.Count; j++)
					{
						for (int k = 0; k < srcDgv.Columns.Count; k++)
						{
							table.Cell(j + 1, k + 1).Range.Text = srcDgv[k, j - 1].Value.ToString();
						}
					}
					document.SaveAs(ref fileName, ref value, ref value, ref value, ref value, ref value, ref value, ref value, ref value, ref value, ref value, ref value, ref value, ref value, ref value, ref value);
					document.Close(ref value, ref value, ref value);
					MessageBox.Show("数据已经成功导出到：" + saveFileDialog.FileName.ToString(), "导出完成", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
				}
				catch (Exception ex)
				{
					MessageBox.Show(ex.Message, "友情提示", MessageBoxButtons.OK);
				}
				finally
				{
					application.Quit(ref value, ref value, ref value);
				}
			}
		}

		public static void DataGridViewToExcel(List<DataGridView> listDgv, LoadCalculationForms form)
		{
			int count = listDgv[0].Rows.Count;
			int count2 = listDgv[0].Columns.Count;
			if (count <= 0)
			{
				MessageBox.Show("没有数据可供保存 ", "提示 ", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
				return;
			}
			if (count2 <= 0)
			{
				MessageBox.Show("没有数据可供保存 ", "提示 ", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
				return;
			}
			if (count > 65536)
			{
				MessageBox.Show("数据记录数太多(最多不能超过65536条)，不能保存 ", "提示 ", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
				return;
			}
			if (count2 > 255)
			{
				MessageBox.Show("数据记录行数太多，不能保存 ", "提示 ", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
				return;
			}
			Microsoft.Office.Interop.Excel.Application application = null;
			Microsoft.Office.Interop.Excel.Worksheet worksheet = null;
            try
            {
            }
            //{
            //    application = (Microsoft.Office.Interop.Excel.Application)Activator.CreateInstance(Marshal.GetTypeFromCLSID(new Guid("00024500-0000-0000-C000-000000000046")));
            //    Microsoft.Office.Interop.Excel.Workbook workbook = application.Workbooks.Add(Missing.Value);
            //    if (DataCalculationAndHelper.<>o__4.<>p__0 == null)
            //    {
            //        DataCalculationAndHelper.<>o__4.<>p__0 = CallSite<Func<CallSite, object, Microsoft.Office.Interop.Excel.Worksheet>>.Create(Microsoft.CSharp.RuntimeBinder.Binder.Convert(CSharpBinderFlags.ConvertExplicit, typeof(Microsoft.Office.Interop.Excel.Worksheet), typeof(DataCalculationAndHelper)));
            //    }
            //    worksheet = DataCalculationAndHelper.<>o__4.<>p__0.Target(DataCalculationAndHelper.<>o__4.<>p__0, workbook.ActiveSheet);
            //    application.Visible = true;
            //    Microsoft.Office.Interop.Excel.Range range = worksheet.get_Range("C1", "M4");
            //    range.Merge(Type.Missing);
            //    range.set_Value(Type.Missing, "负荷计算");
            //    range.Font.Size = 40;
            //    range.Font.Color = System.Drawing.Color.Red;
            //    range.HorizontalAlignment = XlHAlign.xlHAlignCenter;
            //    int num = 5;
            //    int num2 = 0;
            //    foreach (DataGridView dataGridView in listDgv)
            //    {
            //        if (num2 == 1)
            //        {
            //            num += 3;
            //            if (DataCalculationAndHelper.<>o__4.<>p__3 == null)
            //            {
            //                DataCalculationAndHelper.<>o__4.<>p__3 = CallSite<Func<CallSite, object, Microsoft.Office.Interop.Excel.Range>>.Create(Microsoft.CSharp.RuntimeBinder.Binder.Convert(CSharpBinderFlags.None, typeof(Microsoft.Office.Interop.Excel.Range), typeof(DataCalculationAndHelper)));
            //            }
            //            Func<CallSite, object, Microsoft.Office.Interop.Excel.Range> target = DataCalculationAndHelper.<>o__4.<>p__3.Target;
            //            CallSite <>p__ = DataCalculationAndHelper.<>o__4.<>p__3;
            //            if (DataCalculationAndHelper.<>o__4.<>p__2 == null)
            //            {
            //                DataCalculationAndHelper.<>o__4.<>p__2 = CallSite<Func<CallSite, object, object, object, object>>.Create(Microsoft.CSharp.RuntimeBinder.Binder.GetIndex(CSharpBinderFlags.None, typeof(DataCalculationAndHelper), new CSharpArgumentInfo[]
            //                {
            //                    CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null),
            //                    CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null),
            //                    CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null)
            //                }));
            //            }
            //            Func<CallSite, object, object, object, object> target2 = DataCalculationAndHelper.<>o__4.<>p__2.Target;
            //            CallSite <>p__2 = DataCalculationAndHelper.<>o__4.<>p__2;
            //            if (DataCalculationAndHelper.<>o__4.<>p__1 == null)
            //            {
            //                DataCalculationAndHelper.<>o__4.<>p__1 = CallSite<Func<CallSite, Microsoft.Office.Interop.Excel.Worksheet, object>>.Create(Microsoft.CSharp.RuntimeBinder.Binder.GetMember(CSharpBinderFlags.ResultIndexed, "Range", typeof(DataCalculationAndHelper), new CSharpArgumentInfo[]
            //                {
            //                    CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.UseCompileTimeType, null)
            //                }));
            //            }
            //            Microsoft.Office.Interop.Excel.Range range2 = target(<>p__, target2(<>p__2, DataCalculationAndHelper.<>o__4.<>p__1.Target(DataCalculationAndHelper.<>o__4.<>p__1, worksheet), worksheet.Cells[num - 1, 3], worksheet.Cells[num - 1, dataGridView.Columns.Count + 2]));
            //            range2.Merge(Type.Missing);
            //            range2.set_Value(Type.Missing, "计算结果(不计入补偿容量)：");
            //            range2.Font.Color = System.Drawing.Color.Black;
            //            range2.HorizontalAlignment = XlHAlign.xlHAlignLeft;
            //        }
            //        else if (num2 == 2)
            //        {
            //            num += 3;
            //            if (DataCalculationAndHelper.<>o__4.<>p__6 == null)
            //            {
            //                DataCalculationAndHelper.<>o__4.<>p__6 = CallSite<Func<CallSite, object, Microsoft.Office.Interop.Excel.Range>>.Create(Microsoft.CSharp.RuntimeBinder.Binder.Convert(CSharpBinderFlags.None, typeof(Microsoft.Office.Interop.Excel.Range), typeof(DataCalculationAndHelper)));
            //            }
            //            Func<CallSite, object, Microsoft.Office.Interop.Excel.Range> target3 = DataCalculationAndHelper.<>o__4.<>p__6.Target;
            //            CallSite <>p__3 = DataCalculationAndHelper.<>o__4.<>p__6;
            //            if (DataCalculationAndHelper.<>o__4.<>p__5 == null)
            //            {
            //                DataCalculationAndHelper.<>o__4.<>p__5 = CallSite<Func<CallSite, object, object, object, object>>.Create(Microsoft.CSharp.RuntimeBinder.Binder.GetIndex(CSharpBinderFlags.None, typeof(DataCalculationAndHelper), new CSharpArgumentInfo[]
            //                {
            //                    CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null),
            //                    CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null),
            //                    CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null)
            //                }));
            //            }
            //            Func<CallSite, object, object, object, object> target4 = DataCalculationAndHelper.<>o__4.<>p__5.Target;
            //            CallSite <>p__4 = DataCalculationAndHelper.<>o__4.<>p__5;
            //            if (DataCalculationAndHelper.<>o__4.<>p__4 == null)
            //            {
            //                DataCalculationAndHelper.<>o__4.<>p__4 = CallSite<Func<CallSite, Microsoft.Office.Interop.Excel.Worksheet, object>>.Create(Microsoft.CSharp.RuntimeBinder.Binder.GetMember(CSharpBinderFlags.ResultIndexed, "Range", typeof(DataCalculationAndHelper), new CSharpArgumentInfo[]
            //                {
            //                    CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.UseCompileTimeType, null)
            //                }));
            //            }
            //            Microsoft.Office.Interop.Excel.Range range3 = target3(<>p__3, target4(<>p__4, DataCalculationAndHelper.<>o__4.<>p__4.Target(DataCalculationAndHelper.<>o__4.<>p__4, worksheet), worksheet.Cells[num - 1, 3], worksheet.Cells[num - 1, dataGridView.Columns.Count + 2]));
            //            range3.Merge(Type.Missing);
            //            range3.set_Value(Type.Missing, "计算结果(计入补偿容量)：");
            //            range3.Font.Color = System.Drawing.Color.Black;
            //            range3.HorizontalAlignment = XlHAlign.xlHAlignLeft;
            //        }
            //        if (DataCalculationAndHelper.<>o__4.<>p__9 == null)
            //        {
            //            DataCalculationAndHelper.<>o__4.<>p__9 = CallSite<Func<CallSite, object, Microsoft.Office.Interop.Excel.Range>>.Create(Microsoft.CSharp.RuntimeBinder.Binder.Convert(CSharpBinderFlags.None, typeof(Microsoft.Office.Interop.Excel.Range), typeof(DataCalculationAndHelper)));
            //        }
            //        Func<CallSite, object, Microsoft.Office.Interop.Excel.Range> target5 = DataCalculationAndHelper.<>o__4.<>p__9.Target;
            //        CallSite <>p__5 = DataCalculationAndHelper.<>o__4.<>p__9;
            //        if (DataCalculationAndHelper.<>o__4.<>p__8 == null)
            //        {
            //            DataCalculationAndHelper.<>o__4.<>p__8 = CallSite<Func<CallSite, object, object, object, object>>.Create(Microsoft.CSharp.RuntimeBinder.Binder.GetIndex(CSharpBinderFlags.None, typeof(DataCalculationAndHelper), new CSharpArgumentInfo[]
            //            {
            //                CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null),
            //                CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null),
            //                CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null)
            //            }));
            //        }
            //        Func<CallSite, object, object, object, object> target6 = DataCalculationAndHelper.<>o__4.<>p__8.Target;
            //        CallSite <>p__6 = DataCalculationAndHelper.<>o__4.<>p__8;
            //        if (DataCalculationAndHelper.<>o__4.<>p__7 == null)
            //        {
            //            DataCalculationAndHelper.<>o__4.<>p__7 = CallSite<Func<CallSite, Microsoft.Office.Interop.Excel.Worksheet, object>>.Create(Microsoft.CSharp.RuntimeBinder.Binder.GetMember(CSharpBinderFlags.ResultIndexed, "Range", typeof(DataCalculationAndHelper), new CSharpArgumentInfo[]
            //            {
            //                CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.UseCompileTimeType, null)
            //            }));
            //        }
            //        Microsoft.Office.Interop.Excel.Range range4 = target5(<>p__5, target6(<>p__6, DataCalculationAndHelper.<>o__4.<>p__7.Target(DataCalculationAndHelper.<>o__4.<>p__7, worksheet), worksheet.Cells[num, 3], worksheet.Cells[num + dataGridView.Rows.Count, dataGridView.Columns.Count + 2]));
            //        range4.Borders.Color = System.Drawing.Color.Red;
            //        range4.EntireColumn.AutoFit();
            //        range4.Borders.LineStyle = 1;
            //        int num3 = 3;
            //        for (int i = 0; i < dataGridView.ColumnCount; i++)
            //        {
            //            if (dataGridView.Columns[i].Visible)
            //            {
            //                application.Cells[num, num3] = dataGridView.Columns[i].HeaderText.Trim();
            //                num3++;
            //            }
            //        }
            //        for (int j = 0; j <= dataGridView.RowCount - 1; j++)
            //        {
            //            num3 = 3;
            //            for (int k = 0; k < dataGridView.Columns.Count; k++)
            //            {
            //                if (dataGridView.Columns[k].Visible)
            //                {
            //                    try
            //                    {
            //                        if (dataGridView.Rows[j].Cells[k].Value == null)
            //                        {
            //                            application.Cells[num + 1, num3] = "";
            //                        }
            //                        else
            //                        {
            //                            application.Cells[num + 1, num3] = dataGridView.Rows[j].Cells[k].Value.ToString().Trim();
            //                        }
            //                        num3++;
            //                    }
            //                    catch (Exception)
            //                    {
            //                    }
            //                }
            //            }
            //            num++;
            //        }
            //        num2++;
            //    }
            //    if (DataCalculationAndHelper.<>o__4.<>p__12 == null)
            //    {
            //        DataCalculationAndHelper.<>o__4.<>p__12 = CallSite<Func<CallSite, object, Microsoft.Office.Interop.Excel.Range>>.Create(Microsoft.CSharp.RuntimeBinder.Binder.Convert(CSharpBinderFlags.None, typeof(Microsoft.Office.Interop.Excel.Range), typeof(DataCalculationAndHelper)));
            //    }
            //    Func<CallSite, object, Microsoft.Office.Interop.Excel.Range> target7 = DataCalculationAndHelper.<>o__4.<>p__12.Target;
            //    CallSite <>p__7 = DataCalculationAndHelper.<>o__4.<>p__12;
            //    if (DataCalculationAndHelper.<>o__4.<>p__11 == null)
            //    {
            //        DataCalculationAndHelper.<>o__4.<>p__11 = CallSite<Func<CallSite, object, object, object, object>>.Create(Microsoft.CSharp.RuntimeBinder.Binder.GetIndex(CSharpBinderFlags.None, typeof(DataCalculationAndHelper), new CSharpArgumentInfo[]
            //        {
            //            CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null),
            //            CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null),
            //            CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null)
            //        }));
            //    }
            //    Func<CallSite, object, object, object, object> target8 = DataCalculationAndHelper.<>o__4.<>p__11.Target;
            //    CallSite <>p__8 = DataCalculationAndHelper.<>o__4.<>p__11;
            //    if (DataCalculationAndHelper.<>o__4.<>p__10 == null)
            //    {
            //        DataCalculationAndHelper.<>o__4.<>p__10 = CallSite<Func<CallSite, Microsoft.Office.Interop.Excel.Worksheet, object>>.Create(Microsoft.CSharp.RuntimeBinder.Binder.GetMember(CSharpBinderFlags.ResultIndexed, "Range", typeof(DataCalculationAndHelper), new CSharpArgumentInfo[]
            //        {
            //            CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.UseCompileTimeType, null)
            //        }));
            //    }
            //    target7(<>p__7, target8(<>p__8, DataCalculationAndHelper.<>o__4.<>p__10.Target(DataCalculationAndHelper.<>o__4.<>p__10, worksheet), worksheet.Cells[num + 2, 3], worksheet.Cells[num + 2, 3])).set_Value(Type.Missing, "变压器选型：");
            //    if (DataCalculationAndHelper.<>o__4.<>p__15 == null)
            //    {
            //        DataCalculationAndHelper.<>o__4.<>p__15 = CallSite<Func<CallSite, object, Microsoft.Office.Interop.Excel.Range>>.Create(Microsoft.CSharp.RuntimeBinder.Binder.Convert(CSharpBinderFlags.None, typeof(Microsoft.Office.Interop.Excel.Range), typeof(DataCalculationAndHelper)));
            //    }
            //    Func<CallSite, object, Microsoft.Office.Interop.Excel.Range> target9 = DataCalculationAndHelper.<>o__4.<>p__15.Target;
            //    CallSite <>p__9 = DataCalculationAndHelper.<>o__4.<>p__15;
            //    if (DataCalculationAndHelper.<>o__4.<>p__14 == null)
            //    {
            //        DataCalculationAndHelper.<>o__4.<>p__14 = CallSite<Func<CallSite, object, object, object, object>>.Create(Microsoft.CSharp.RuntimeBinder.Binder.GetIndex(CSharpBinderFlags.None, typeof(DataCalculationAndHelper), new CSharpArgumentInfo[]
            //        {
            //            CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null),
            //            CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null),
            //            CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null)
            //        }));
            //    }
            //    Func<CallSite, object, object, object, object> target10 = DataCalculationAndHelper.<>o__4.<>p__14.Target;
            //    CallSite <>p__10 = DataCalculationAndHelper.<>o__4.<>p__14;
            //    if (DataCalculationAndHelper.<>o__4.<>p__13 == null)
            //    {
            //        DataCalculationAndHelper.<>o__4.<>p__13 = CallSite<Func<CallSite, Microsoft.Office.Interop.Excel.Worksheet, object>>.Create(Microsoft.CSharp.RuntimeBinder.Binder.GetMember(CSharpBinderFlags.ResultIndexed, "Range", typeof(DataCalculationAndHelper), new CSharpArgumentInfo[]
            //        {
            //            CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.UseCompileTimeType, null)
            //        }));
            //    }
            //    target9(<>p__9, target10(<>p__10, DataCalculationAndHelper.<>o__4.<>p__13.Target(DataCalculationAndHelper.<>o__4.<>p__13, worksheet), worksheet.Cells[num + 3, 3], worksheet.Cells[num + 3, 3])).set_Value(Type.Missing, "负荷率：");
            //    if (DataCalculationAndHelper.<>o__4.<>p__18 == null)
            //    {
            //        DataCalculationAndHelper.<>o__4.<>p__18 = CallSite<Func<CallSite, object, Microsoft.Office.Interop.Excel.Range>>.Create(Microsoft.CSharp.RuntimeBinder.Binder.Convert(CSharpBinderFlags.None, typeof(Microsoft.Office.Interop.Excel.Range), typeof(DataCalculationAndHelper)));
            //    }
            //    Func<CallSite, object, Microsoft.Office.Interop.Excel.Range> target11 = DataCalculationAndHelper.<>o__4.<>p__18.Target;
            //    CallSite <>p__11 = DataCalculationAndHelper.<>o__4.<>p__18;
            //    if (DataCalculationAndHelper.<>o__4.<>p__17 == null)
            //    {
            //        DataCalculationAndHelper.<>o__4.<>p__17 = CallSite<Func<CallSite, object, object, object, object>>.Create(Microsoft.CSharp.RuntimeBinder.Binder.GetIndex(CSharpBinderFlags.None, typeof(DataCalculationAndHelper), new CSharpArgumentInfo[]
            //        {
            //            CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null),
            //            CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null),
            //            CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null)
            //        }));
            //    }
            //    Func<CallSite, object, object, object, object> target12 = DataCalculationAndHelper.<>o__4.<>p__17.Target;
            //    CallSite <>p__12 = DataCalculationAndHelper.<>o__4.<>p__17;
            //    if (DataCalculationAndHelper.<>o__4.<>p__16 == null)
            //    {
            //        DataCalculationAndHelper.<>o__4.<>p__16 = CallSite<Func<CallSite, Microsoft.Office.Interop.Excel.Worksheet, object>>.Create(Microsoft.CSharp.RuntimeBinder.Binder.GetMember(CSharpBinderFlags.ResultIndexed, "Range", typeof(DataCalculationAndHelper), new CSharpArgumentInfo[]
            //        {
            //            CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.UseCompileTimeType, null)
            //        }));
            //    }
            //    target11(<>p__11, target12(<>p__12, DataCalculationAndHelper.<>o__4.<>p__16.Target(DataCalculationAndHelper.<>o__4.<>p__16, worksheet), worksheet.Cells[num + 3, 4], worksheet.Cells[num + 3, 4])).set_Value(Type.Missing, form.tbLoadFactor.Text);
            //    if (DataCalculationAndHelper.<>o__4.<>p__21 == null)
            //    {
            //        DataCalculationAndHelper.<>o__4.<>p__21 = CallSite<Func<CallSite, object, Microsoft.Office.Interop.Excel.Range>>.Create(Microsoft.CSharp.RuntimeBinder.Binder.Convert(CSharpBinderFlags.None, typeof(Microsoft.Office.Interop.Excel.Range), typeof(DataCalculationAndHelper)));
            //    }
            //    Func<CallSite, object, Microsoft.Office.Interop.Excel.Range> target13 = DataCalculationAndHelper.<>o__4.<>p__21.Target;
            //    CallSite <>p__13 = DataCalculationAndHelper.<>o__4.<>p__21;
            //    if (DataCalculationAndHelper.<>o__4.<>p__20 == null)
            //    {
            //        DataCalculationAndHelper.<>o__4.<>p__20 = CallSite<Func<CallSite, object, object, object, object>>.Create(Microsoft.CSharp.RuntimeBinder.Binder.GetIndex(CSharpBinderFlags.None, typeof(DataCalculationAndHelper), new CSharpArgumentInfo[]
            //        {
            //            CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null),
            //            CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null),
            //            CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null)
            //        }));
            //    }
            //    Func<CallSite, object, object, object, object> target14 = DataCalculationAndHelper.<>o__4.<>p__20.Target;
            //    CallSite <>p__14 = DataCalculationAndHelper.<>o__4.<>p__20;
            //    if (DataCalculationAndHelper.<>o__4.<>p__19 == null)
            //    {
            //        DataCalculationAndHelper.<>o__4.<>p__19 = CallSite<Func<CallSite, Microsoft.Office.Interop.Excel.Worksheet, object>>.Create(Microsoft.CSharp.RuntimeBinder.Binder.GetMember(CSharpBinderFlags.ResultIndexed, "Range", typeof(DataCalculationAndHelper), new CSharpArgumentInfo[]
            //        {
            //            CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.UseCompileTimeType, null)
            //        }));
            //    }
            //    target13(<>p__13, target14(<>p__14, DataCalculationAndHelper.<>o__4.<>p__19.Target(DataCalculationAndHelper.<>o__4.<>p__19, worksheet), worksheet.Cells[num + 3, 5], worksheet.Cells[num + 3, 5])).set_Value(Type.Missing, "变压器名称：");
            //    if (DataCalculationAndHelper.<>o__4.<>p__24 == null)
            //    {
            //        DataCalculationAndHelper.<>o__4.<>p__24 = CallSite<Func<CallSite, object, Microsoft.Office.Interop.Excel.Range>>.Create(Microsoft.CSharp.RuntimeBinder.Binder.Convert(CSharpBinderFlags.None, typeof(Microsoft.Office.Interop.Excel.Range), typeof(DataCalculationAndHelper)));
            //    }
            //    Func<CallSite, object, Microsoft.Office.Interop.Excel.Range> target15 = DataCalculationAndHelper.<>o__4.<>p__24.Target;
            //    CallSite <>p__15 = DataCalculationAndHelper.<>o__4.<>p__24;
            //    if (DataCalculationAndHelper.<>o__4.<>p__23 == null)
            //    {
            //        DataCalculationAndHelper.<>o__4.<>p__23 = CallSite<Func<CallSite, object, object, object, object>>.Create(Microsoft.CSharp.RuntimeBinder.Binder.GetIndex(CSharpBinderFlags.None, typeof(DataCalculationAndHelper), new CSharpArgumentInfo[]
            //        {
            //            CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null),
            //            CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null),
            //            CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null)
            //        }));
            //    }
            //    Func<CallSite, object, object, object, object> target16 = DataCalculationAndHelper.<>o__4.<>p__23.Target;
            //    CallSite <>p__16 = DataCalculationAndHelper.<>o__4.<>p__23;
            //    if (DataCalculationAndHelper.<>o__4.<>p__22 == null)
            //    {
            //        DataCalculationAndHelper.<>o__4.<>p__22 = CallSite<Func<CallSite, Microsoft.Office.Interop.Excel.Worksheet, object>>.Create(Microsoft.CSharp.RuntimeBinder.Binder.GetMember(CSharpBinderFlags.ResultIndexed, "Range", typeof(DataCalculationAndHelper), new CSharpArgumentInfo[]
            //        {
            //            CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.UseCompileTimeType, null)
            //        }));
            //    }
            //    Microsoft.Office.Interop.Excel.Range range5 = target15(<>p__15, target16(<>p__16, DataCalculationAndHelper.<>o__4.<>p__22.Target(DataCalculationAndHelper.<>o__4.<>p__22, worksheet), worksheet.Cells[num + 3, 6], worksheet.Cells[num + 3, 6]));
            //    TransformPowerData transformPowerData = (TransformPowerData)form.cmbTransformType.SelectedItem;
            //    range5.set_Value(Type.Missing, transformPowerData.TransformName);
            //    if (DataCalculationAndHelper.<>o__4.<>p__27 == null)
            //    {
            //        DataCalculationAndHelper.<>o__4.<>p__27 = CallSite<Func<CallSite, object, Microsoft.Office.Interop.Excel.Range>>.Create(Microsoft.CSharp.RuntimeBinder.Binder.Convert(CSharpBinderFlags.None, typeof(Microsoft.Office.Interop.Excel.Range), typeof(DataCalculationAndHelper)));
            //    }
            //    Func<CallSite, object, Microsoft.Office.Interop.Excel.Range> target17 = DataCalculationAndHelper.<>o__4.<>p__27.Target;
            //    CallSite <>p__17 = DataCalculationAndHelper.<>o__4.<>p__27;
            //    if (DataCalculationAndHelper.<>o__4.<>p__26 == null)
            //    {
            //        DataCalculationAndHelper.<>o__4.<>p__26 = CallSite<Func<CallSite, object, object, object, object>>.Create(Microsoft.CSharp.RuntimeBinder.Binder.GetIndex(CSharpBinderFlags.None, typeof(DataCalculationAndHelper), new CSharpArgumentInfo[]
            //        {
            //            CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null),
            //            CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null),
            //            CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null)
            //        }));
            //    }
            //    Func<CallSite, object, object, object, object> target18 = DataCalculationAndHelper.<>o__4.<>p__26.Target;
            //    CallSite <>p__18 = DataCalculationAndHelper.<>o__4.<>p__26;
            //    if (DataCalculationAndHelper.<>o__4.<>p__25 == null)
            //    {
            //        DataCalculationAndHelper.<>o__4.<>p__25 = CallSite<Func<CallSite, Microsoft.Office.Interop.Excel.Worksheet, object>>.Create(Microsoft.CSharp.RuntimeBinder.Binder.GetMember(CSharpBinderFlags.ResultIndexed, "Range", typeof(DataCalculationAndHelper), new CSharpArgumentInfo[]
            //        {
            //            CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.UseCompileTimeType, null)
            //        }));
            //    }
            //    target17(<>p__17, target18(<>p__18, DataCalculationAndHelper.<>o__4.<>p__25.Target(DataCalculationAndHelper.<>o__4.<>p__25, worksheet), worksheet.Cells[num + 3, 7], worksheet.Cells[num + 3, 7])).set_Value(Type.Missing, "台数：");
            //    if (DataCalculationAndHelper.<>o__4.<>p__30 == null)
            //    {
            //        DataCalculationAndHelper.<>o__4.<>p__30 = CallSite<Func<CallSite, object, Microsoft.Office.Interop.Excel.Range>>.Create(Microsoft.CSharp.RuntimeBinder.Binder.Convert(CSharpBinderFlags.None, typeof(Microsoft.Office.Interop.Excel.Range), typeof(DataCalculationAndHelper)));
            //    }
            //    Func<CallSite, object, Microsoft.Office.Interop.Excel.Range> target19 = DataCalculationAndHelper.<>o__4.<>p__30.Target;
            //    CallSite <>p__19 = DataCalculationAndHelper.<>o__4.<>p__30;
            //    if (DataCalculationAndHelper.<>o__4.<>p__29 == null)
            //    {
            //        DataCalculationAndHelper.<>o__4.<>p__29 = CallSite<Func<CallSite, object, object, object, object>>.Create(Microsoft.CSharp.RuntimeBinder.Binder.GetIndex(CSharpBinderFlags.None, typeof(DataCalculationAndHelper), new CSharpArgumentInfo[]
            //        {
            //            CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null),
            //            CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null),
            //            CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null)
            //        }));
            //    }
            //    Func<CallSite, object, object, object, object> target20 = DataCalculationAndHelper.<>o__4.<>p__29.Target;
            //    CallSite <>p__20 = DataCalculationAndHelper.<>o__4.<>p__29;
            //    if (DataCalculationAndHelper.<>o__4.<>p__28 == null)
            //    {
            //        DataCalculationAndHelper.<>o__4.<>p__28 = CallSite<Func<CallSite, Microsoft.Office.Interop.Excel.Worksheet, object>>.Create(Microsoft.CSharp.RuntimeBinder.Binder.GetMember(CSharpBinderFlags.ResultIndexed, "Range", typeof(DataCalculationAndHelper), new CSharpArgumentInfo[]
            //        {
            //            CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.UseCompileTimeType, null)
            //        }));
            //    }
            //    target19(<>p__19, target20(<>p__20, DataCalculationAndHelper.<>o__4.<>p__28.Target(DataCalculationAndHelper.<>o__4.<>p__28, worksheet), worksheet.Cells[num + 3, 8], worksheet.Cells[num + 3, 8])).set_Value(Type.Missing, form.numCount.Value);
            //    if (DataCalculationAndHelper.<>o__4.<>p__33 == null)
            //    {
            //        DataCalculationAndHelper.<>o__4.<>p__33 = CallSite<Func<CallSite, object, Microsoft.Office.Interop.Excel.Range>>.Create(Microsoft.CSharp.RuntimeBinder.Binder.Convert(CSharpBinderFlags.None, typeof(Microsoft.Office.Interop.Excel.Range), typeof(DataCalculationAndHelper)));
            //    }
            //    Func<CallSite, object, Microsoft.Office.Interop.Excel.Range> target21 = DataCalculationAndHelper.<>o__4.<>p__33.Target;
            //    CallSite <>p__21 = DataCalculationAndHelper.<>o__4.<>p__33;
            //    if (DataCalculationAndHelper.<>o__4.<>p__32 == null)
            //    {
            //        DataCalculationAndHelper.<>o__4.<>p__32 = CallSite<Func<CallSite, object, object, object, object>>.Create(Microsoft.CSharp.RuntimeBinder.Binder.GetIndex(CSharpBinderFlags.None, typeof(DataCalculationAndHelper), new CSharpArgumentInfo[]
            //        {
            //            CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null),
            //            CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null),
            //            CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null)
            //        }));
            //    }
            //    Func<CallSite, object, object, object, object> target22 = DataCalculationAndHelper.<>o__4.<>p__32.Target;
            //    CallSite <>p__22 = DataCalculationAndHelper.<>o__4.<>p__32;
            //    if (DataCalculationAndHelper.<>o__4.<>p__31 == null)
            //    {
            //        DataCalculationAndHelper.<>o__4.<>p__31 = CallSite<Func<CallSite, Microsoft.Office.Interop.Excel.Worksheet, object>>.Create(Microsoft.CSharp.RuntimeBinder.Binder.GetMember(CSharpBinderFlags.ResultIndexed, "Range", typeof(DataCalculationAndHelper), new CSharpArgumentInfo[]
            //        {
            //            CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.UseCompileTimeType, null)
            //        }));
            //    }
            //    target21(<>p__21, target22(<>p__22, DataCalculationAndHelper.<>o__4.<>p__31.Target(DataCalculationAndHelper.<>o__4.<>p__31, worksheet), worksheet.Cells[num + 3, 9], worksheet.Cells[num + 3, 9])).set_Value(Type.Missing, "变压器规格：");
            //    if (DataCalculationAndHelper.<>o__4.<>p__36 == null)
            //    {
            //        DataCalculationAndHelper.<>o__4.<>p__36 = CallSite<Func<CallSite, object, Microsoft.Office.Interop.Excel.Range>>.Create(Microsoft.CSharp.RuntimeBinder.Binder.Convert(CSharpBinderFlags.None, typeof(Microsoft.Office.Interop.Excel.Range), typeof(DataCalculationAndHelper)));
            //    }
            //    Func<CallSite, object, Microsoft.Office.Interop.Excel.Range> target23 = DataCalculationAndHelper.<>o__4.<>p__36.Target;
            //    CallSite <>p__23 = DataCalculationAndHelper.<>o__4.<>p__36;
            //    if (DataCalculationAndHelper.<>o__4.<>p__35 == null)
            //    {
            //        DataCalculationAndHelper.<>o__4.<>p__35 = CallSite<Func<CallSite, object, object, object, object>>.Create(Microsoft.CSharp.RuntimeBinder.Binder.GetIndex(CSharpBinderFlags.None, typeof(DataCalculationAndHelper), new CSharpArgumentInfo[]
            //        {
            //            CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null),
            //            CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null),
            //            CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null)
            //        }));
            //    }
            //    Func<CallSite, object, object, object, object> target24 = DataCalculationAndHelper.<>o__4.<>p__35.Target;
            //    CallSite <>p__24 = DataCalculationAndHelper.<>o__4.<>p__35;
            //    if (DataCalculationAndHelper.<>o__4.<>p__34 == null)
            //    {
            //        DataCalculationAndHelper.<>o__4.<>p__34 = CallSite<Func<CallSite, Microsoft.Office.Interop.Excel.Worksheet, object>>.Create(Microsoft.CSharp.RuntimeBinder.Binder.GetMember(CSharpBinderFlags.ResultIndexed, "Range", typeof(DataCalculationAndHelper), new CSharpArgumentInfo[]
            //        {
            //            CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.UseCompileTimeType, null)
            //        }));
            //    }
            //    target23(<>p__23, target24(<>p__24, DataCalculationAndHelper.<>o__4.<>p__34.Target(DataCalculationAndHelper.<>o__4.<>p__34, worksheet), worksheet.Cells[num + 3, 10], worksheet.Cells[num + 3, 10])).set_Value(Type.Missing, form.cmbTranPower.Text);
            //    if (DataCalculationAndHelper.<>o__4.<>p__39 == null)
            //    {
            //        DataCalculationAndHelper.<>o__4.<>p__39 = CallSite<Func<CallSite, object, Microsoft.Office.Interop.Excel.Range>>.Create(Microsoft.CSharp.RuntimeBinder.Binder.Convert(CSharpBinderFlags.None, typeof(Microsoft.Office.Interop.Excel.Range), typeof(DataCalculationAndHelper)));
            //    }
            //    Func<CallSite, object, Microsoft.Office.Interop.Excel.Range> target25 = DataCalculationAndHelper.<>o__4.<>p__39.Target;
            //    CallSite <>p__25 = DataCalculationAndHelper.<>o__4.<>p__39;
            //    if (DataCalculationAndHelper.<>o__4.<>p__38 == null)
            //    {
            //        DataCalculationAndHelper.<>o__4.<>p__38 = CallSite<Func<CallSite, object, object, object, object>>.Create(Microsoft.CSharp.RuntimeBinder.Binder.GetIndex(CSharpBinderFlags.None, typeof(DataCalculationAndHelper), new CSharpArgumentInfo[]
            //        {
            //            CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null),
            //            CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null),
            //            CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null)
            //        }));
            //    }
            //    Func<CallSite, object, object, object, object> target26 = DataCalculationAndHelper.<>o__4.<>p__38.Target;
            //    CallSite <>p__26 = DataCalculationAndHelper.<>o__4.<>p__38;
            //    if (DataCalculationAndHelper.<>o__4.<>p__37 == null)
            //    {
            //        DataCalculationAndHelper.<>o__4.<>p__37 = CallSite<Func<CallSite, Microsoft.Office.Interop.Excel.Worksheet, object>>.Create(Microsoft.CSharp.RuntimeBinder.Binder.GetMember(CSharpBinderFlags.ResultIndexed, "Range", typeof(DataCalculationAndHelper), new CSharpArgumentInfo[]
            //        {
            //            CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.UseCompileTimeType, null)
            //        }));
            //    }
            //    Microsoft.Office.Interop.Excel.Range range6 = target25(<>p__25, target26(<>p__26, DataCalculationAndHelper.<>o__4.<>p__37.Target(DataCalculationAndHelper.<>o__4.<>p__37, worksheet), worksheet.Cells[num + 3, 3], worksheet.Cells[num + 3, 10]));
            //    range6.HorizontalAlignment = XlHAlign.xlHAlignLeft;
            //    range6.Borders.Color = System.Drawing.Color.Red;
            //    range6.EntireColumn.AutoFit();
            //    range6.Borders.LineStyle = 1;
            //}
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "警告 ", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
		}

		public static string MathDecimal(double var, int n)
		{
			return var.ToString("0.00");
		}

		public static double ActivePower(double Power, double NeedFactor)
		{
			return Convert.ToDouble(Power * NeedFactor);
		}

		public static double RectivePower(double activePower, double EquipPower)
		{
			return Convert.ToDouble(activePower * Math.Tan(Math.Acos(EquipPower)));
		}

		public static double Getviewpower(double activePower, double EquipPower)
		{
			return Convert.ToDouble(activePower / EquipPower);
		}

		public static double ViewPower(double activePower, double reactivePower)
		{
			return Math.Sqrt(Math.Pow(activePower, 2.0) + Math.Pow(reactivePower, 2.0));
		}

		public static double EleCurrentThree(double viewPower)
		{
			return viewPower * 1000.0 / (Math.Sqrt(3.0) * 380.0);
		}

		public static double EleCurrentOne(double viewPower)
		{
			return viewPower * 1000.0 / 220.0;
		}

		public static double TotolPowerFactor(double reactivePower, double activePower)
		{
			return Math.Cos(Math.Atan(reactivePower / activePower));
		}

		public static double CalculatComFator(double activePower, double reActivePower, double ActiveLoadFactor, double ReactiveLoadFactor)
		{
			double num = Math.Pow(ReactiveLoadFactor * reActivePower / (activePower * ActiveLoadFactor), 2.0);
			return Math.Sqrt(1.0 / (1.0 + num));
		}

		public static double CompasationCapacity(double compation, double activePower, double compasationBefore, double compasationAfeter)
		{
			return compation * activePower * (compasationBefore - compasationAfeter);
		}

		public static double cosTransformTan(double cos)
		{
			return Math.Sqrt(1.0 - Math.Pow(cos, 2.0)) / cos;
		}

		public static void keyPressXS(KeyPressEventArgs e, DataGridViewTextBoxEditingControl dgvTxt, int colIndex)
		{
			if (colIndex == 1)
			{
				e.Handled = false;
				return;
			}
			if (char.IsNumber(e.KeyChar) || e.KeyChar == '.' || e.KeyChar == '\b')
			{
				e.Handled = false;
				int num = 0;
				int num2 = 0;
				bool flag = false;
				if (dgvTxt.Text.Length == 0 && e.KeyChar == '.')
				{
					e.Handled = true;
				}
				for (int i = 0; i < dgvTxt.Text.Length; i++)
				{
					if (dgvTxt.Text[i] == '.')
					{
						num++;
						flag = true;
					}
					if (flag && char.IsNumber(dgvTxt.Text[i]) && e.KeyChar != '\b')
					{
						num2++;
					}
					if (num >= 1 && e.KeyChar == '.')
					{
						e.Handled = true;
					}
					if (num2 == 2 && char.IsNumber(dgvTxt.Text[i]) && e.KeyChar != '\b' && dgvTxt.Text.Length - dgvTxt.SelectionStart < 3 && dgvTxt.SelectedText != dgvTxt.Text)
					{
						e.Handled = true;
					}
				}
				return;
			}
			e.Handled = true;
		}

		public static List<TransformListData> GetTransformList()
		{
			List<TransformListData> result = new List<TransformListData>();
			string connStr = "Data Source=" + AssistFunc.GetAppRootPath() + "\\Data\\ElectricalData\\ElectricData.db;Initial Catalog=sqlite;Integrated Security=True;Max Pool Size=10";
			try
			{
				SqLiteHelper.SqlLiteDatabase(connStr);
			}
			catch (Exception)
			{
			}
            System.Data.DataTable dataTable = HYElectricCommon.Database.ExecQuery(string.Format("select * from TransformerType", Array.Empty<object>()));
			if (dataTable == null)
			{
				return null;
			}
			for (int i = 0; i < dataTable.Rows.Count; i++)
			{
			}
			return result;
		}

		public static List<TransformPowerData> GetTransformData(ExternalCommandData cmdData)
		{
			List<TransformPowerData> result;
			try
			{
				List<TransformPowerData> list = new List<TransformPowerData>();
				DbCategory dbCategory = FamilyLibDatabase.GetSqliteDB(SubjectType.Electric, cmdData.Application.Application.VersionNumber).CategoryTable["变压器"];
				List<DbCategory> allChildren = dbCategory.GetAllChildren(true);
				List<DbFamily> list2 = new List<DbFamily>();
				if (allChildren.Count > 0)
				{
					using (List<DbCategory>.Enumerator enumerator = allChildren.GetEnumerator())
					{
						while (enumerator.MoveNext())
						{
							DbCategory dbCategory2 = enumerator.Current;
							list2.AddRange(dbCategory2.GetAllFamilies(false, CheckType.All));
						}
						goto IL_91;
					}
				}
				list2.AddRange(dbCategory.GetAllFamilies(true, CheckType.All));
				IL_91:
				foreach (DbFamily dbFamily in list2)
				{
					TransformPowerData transformPowerData = new TransformPowerData();
                    System.Data.DataTable dataTable = dbFamily.Database.TypeTable.DataTable(dbFamily);
					Dictionary<string, double> dictionary = new Dictionary<string, double>();
					transformPowerData.TransformName = dbFamily.Name;
					for (int i = 0; i < dataTable.Rows.Count; i++)
					{
						if (!dictionary.ContainsKey(dataTable.Rows[i]["规格名"].ToString()))
						{
							dictionary.Add(dataTable.Rows[i]["规格名"].ToString(), Convert.ToDouble(dataTable.Rows[i]["额定容量"]));
						}
					}
					transformPowerData.TransformDic = dictionary;
					list.Add(transformPowerData);
				}
				result = list;
			}
			catch (Exception ex)
			{
				MessageBox.Show(ex.Message);
				result = null;
			}
			return result;
		}

		public static List<TransformPowerData> GetTransformPowerData()
		{
			List<TransformPowerData> list = new List<TransformPowerData>();
			TransformPowerData transformPowerData = null;
			string connStr = "Data Source=" + AssistFunc.GetAppRootPath() + "\\Data\\ElectricalData\\ElectricData.db;Initial Catalog=sqlite;Integrated Security=True;Max Pool Size=10";
			try
			{
				SqLiteHelper.SqlLiteDatabase(connStr);
			}
			catch (Exception)
			{
			}
            System.Data.DataTable dataTable = HYElectricCommon.Database.ExecQuery(string.Format("select * from TransformerCapacity order by TransformerTypeID", Array.Empty<object>()));
			List<string> list2 = new List<string>();
			List<double> list3 = new List<double>();
			for (int i = 0; i < dataTable.Rows.Count; i++)
			{
				DataRow dataRow = dataTable.Rows[i];
				string text = dataRow["TransformerTypeID"].ToString();
				double item = Convert.ToDouble(dataRow["Capacity"]);
				if (list2.Count == 0)
				{
					list2.Add(text);
					transformPowerData = new TransformPowerData();
					transformPowerData.TransformId = text;
					list3.Add(item);
				}
				else if (!list2.Contains(text))
				{
					transformPowerData.PowerItem = list3;
					list.Add(transformPowerData);
					list3.Clear();
					transformPowerData = new TransformPowerData();
					transformPowerData.TransformId = text;
					list3.Add(item);
				}
				else
				{
					list3.Add(item);
					if (dataTable.Rows.Count - 1 == i)
					{
						transformPowerData.PowerItem = list3;
						list.Add(transformPowerData);
					}
				}
			}
			return list;
		}
	}
}
